import VGE from './VGE';

/**
 * VGE工具的父类，其他工具都将继承此类
 * 子类中需要重写start和cancel方法
 */
export class Tool {
	/**
	 * 工具启动函数
	 * @returns {boolean}
	 */
	start() {
		return false;
	}

	/**
	 * 工具结束函数
	 * @returns {boolean}
	 */
	cancel() {
		return false;
	}

	/**
	 * 工具结束
	 * @returns {boolean}
	 */
	end(toolId) {
		VGE.toolManager.onSelectToolEnd(toolId);
		return this.cancel();
	}

	/**
	 * 工具运行，并且toolManager记录此工具
	 * @param toolId
	 * @returns {boolean}
	 */
	run(toolId) {
		VGE.toolManager.setActiveTool(toolId, this);
		return this.start();
	}
}

/**
 * 工具注册者，负责工具注册、运行、结束
 */
export class ToolRegistry {
	constructor() {
		this.list = new Map();
	}

	/**
	 * 工具注册：将工具记录在map集合
	 * @param tool
	 */
	register(tool) {
		this.list.set(tool.toolId, tool);
	}

	/**
	 * 移除注册工具
	 * @param tool
	 */
	unRegister(tool) {
		this.list.delete(tool.toolId);
	}

	/**
	 * 根据指定d查找工具
	 * @param toolId
	 * @returns {any}
	 */
	find(toolId) {
		return this.list.get(toolId);
	}

	/**
	 * 获取已注册工具列表
	 * @returns {Map<any, any>}
	 */
	getToolList() {
		return this.list;
	}

	/**
	 * 获取指定id的工具实例
	 * @param toolId
	 * @param args
	 * @returns {*|undefined}
	 */
	create(toolId, ...args) {
		// const scene = VGE._sceneTo
		// const key = scene + '_' + toolId + '_' + JSON.stringify(args.slice(1))
		// const tool = VGE.toolManager.find(toolId)
		// if (tool?.key === key) return tool

		const TooClass = this.find(toolId);
		if (!TooClass) alert('未找到此工具！请检查是否已注册');
		return TooClass ? new TooClass(...args) : undefined;
	}

	/**
	 * 运行指定id的工具
	 * @param toolId
	 * @param args
	 * @returns {*}
	 */
	run(toolId, ...args) {
		const tool = this.create(toolId, ...args);
		tool && (tool.toolId = toolId);
		return tool && tool.run(toolId);
	}

	/**
	 * 结束指定id的工具
	 * @param toolId
	 */
	end(toolId) {
		const tool = VGE.toolManager.find(toolId);
		tool && tool.end(toolId);
	}
}

/**
 * 工具管理员，管理已启动工具
 * 处理工具联动
 */
export class ToolManager {
	constructor() {
		this.activeTool = new Map();
		this.currentTool = null;
		this.eventListener = [];
		this.toolRelation = VGE.config.toolRelation || new Map();
	}

	/**
	 * 根据指定id查找工具
	 * @param toolId
	 * @returns {any}
	 */
	find(toolId) {
		return this.activeTool.get(toolId);
	}

	/**
	 * 记录启动的工具
	 * @param toolId
	 * @param newTool
	 */
	setActiveTool(toolId, newTool) {
		this.setCurrentTool(newTool);
		this.activeTool.set(toolId, newTool);
		this.onToolRunning();
	}

	/**
	 * 记录当前工具
	 * @param newTool
	 */
	setCurrentTool(newTool) {
		// 判断工具联动关系
		const currentTool = this.currentTool;

		if (currentTool) {
			const single = this.singleTool(currentTool, newTool);
			if (single) currentTool.end(currentTool.toolId);
		}

		this.currentTool = newTool;
	}

	/**
	 * 结束启动的工具
	 */
	endActiveTool() {
		this.activeTool.forEach((tool, toolId) => {
			tool && tool.end(toolId);
		});
	}

	onSelectToolEnd(toolId) {
		this.activeTool.delete(toolId);
		if (toolId === this.currentTool.toolId) {
			this.currentTool = null;
		}
		if (!this.activeTool.size) {
			this.offListener();
		}
	}

	/**
	 * 结束当前工具
	 */
	endCurrentTool() {
		const currentTool = this.currentTool;
		currentTool && currentTool.end(currentTool.toolId);
	}

	/**
	 * 事件处理
	 * @param ev
	 */
	eventHandler(ev) {
		if (ev.keyCode === 27) {
			ev.returnValue = false;
			ev.ctrlKey && ev.shiftKey
				? VGE.toolManager.endActiveTool()
				: VGE.toolManager.endCurrentTool();
		}
	}

	/**
	 * 监听工具启动
	 */
	onToolRunning() {
		const listener = [];
		['keydown', 'keyup'].forEach((type) => {
			document.addEventListener(type, this.eventHandler, false);
			listener.push(() => {
				document.removeEventListener(type, this.eventHandler, false);
			});
		});
		this.eventListener = listener;
	}

	offListener() {
		this.eventListener.forEach((remove) => remove());
		this.eventListener = [];
	}

	setToolRelation(mapData) {
		this.toolRelation = mapData;
	}

	/**
	 * 判断工具联动
	 * 如果已打开工具在新打开工具的关系列表中，则可以继续存在
	 * @param oldTool
	 * @param newTool
	 * @returns {boolean}
	 */
	singleTool(oldTool, newTool) {
		const result = this.toolRelation.get(newTool.toolId) ?? [];
		// 没找到为false，返回true
		return !result.includes(oldTool.toolId);
	}

	/**
	 * 设置当前工具鼠标样式
	 * @param cursor
	 */
	setCursor(cursor) {
		document.querySelector('canvas').style.cursor = cursor;
	}
}

export class ToolCursor {
	static distanceCursor(color) {
		let svg =
			'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="icon" x="0px" y="0px" width="36px" height="36px" viewBox="0 0 1035 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M326.059903 818.086957v-222.608696c0-16.695652 11.130435-27.826087 27.826087-27.826087s27.826087 11.130435 27.826087 27.826087v222.608696c0 16.695652-11.130435 27.826087-27.826087 27.826086s-27.826087-13.913043-27.826087-27.826086z"  /><path d="M353.88599 851.478261c-19.478261 0-33.391304-16.695652-33.391304-33.391304v-222.608696c0-19.478261 16.695652-33.391304 33.391304-33.391304s33.391304 16.695652 33.391305 33.391304v222.608696c2.782609 16.695652-13.913043 33.391304-33.391305 33.391304z m0-278.26087c-11.130435 0-22.26087 8.347826-22.260869 22.26087v222.608696c0 11.130435 8.347826 22.26087 22.260869 22.260869s22.26087-8.347826 22.26087-22.260869v-222.608696c0-13.913043-11.130435-22.26087-22.26087-22.26087z" fill="#DDDDDD" /><path d="M409.538164 720.695652v-27.826087h83.478261v27.826087h-83.478261z m139.130435 0v-27.826087h83.478261v27.826087h-83.478261z m139.130435 0v-27.826087h83.478261v27.826087h-83.478261z m139.130435 0v-27.826087h83.47826v27.826087h-83.47826z"  /><path d="M918.755556 726.26087h-97.391305v-41.739131h97.391305v41.739131z m-83.478261-13.913044h69.565217v-13.913043h-69.565217v13.913043z m-55.652174 13.913044h-97.391305v-41.739131h97.391305v41.739131z m-83.478261-13.913044h69.565217v-13.913043h-69.565217v13.913043z m-55.652174 13.913044h-97.391304v-41.739131h97.391304v41.739131z m-83.478261-13.913044h69.565218v-13.913043h-69.565218v13.913043z m-55.652174 13.913044h-97.391304v-41.739131h97.391304v41.739131z m-83.478261-13.913044h69.565218v-13.913043h-69.565218v13.913043z" fill="#DDDDDD" /><path d="M865.88599 651.130435h111.304348v111.304348h-111.304348z" fill="#DDDDDD" /><path d="M1005.016425 790.26087h-166.956522v-166.956522h166.956522v166.956522z m-111.304348-55.652174h55.652174v-55.652174h-55.652174v55.652174z"  /><path d="M1013.364251 795.826087h-180.869565v-180.869565h180.869565v180.869565z m-166.956522-13.913044h153.043479v-153.043478h-153.043479v153.043478z m111.304348-41.73913h-69.565217v-69.565217h69.565217v69.565217z m-55.652174-13.913043h41.739131v-41.739131h-41.739131v41.739131z" fill="#DDDDDD" /><path d="M81.190338 645.565217s-2.782609 0 0 0c-5.565217-2.782609-11.130435-5.565217-11.130435-8.347826L11.625121 22.26087c0-2.782609 2.782609-8.347826 5.565217-11.130435H22.755556c2.782609 0 5.565217 0 5.565217 2.782608l500.869565 356.173914c2.782609 2.782609 5.565217 8.347826 2.782609 11.130434 0 5.565217-5.565217 8.347826-8.347826 8.347826l-275.478261 27.826087-161.391304 225.391305s-2.782609 2.782609-5.565218 2.782608z"  /><path d="M22.755556 22.26087l500.869565 356.173913-278.26087 27.826087L81.190338 634.434783 22.755556 22.26087m0-22.26087c-2.782609 0-8.347826 0-11.130435 2.782609-8.347826 2.782609-11.130435 11.130435-11.130435 19.478261l58.434783 612.173913c0 8.347826 5.565217 16.695652 16.695652 19.47826h5.565217c5.565217 0 13.913043-2.782609 16.695652-8.347826l158.608696-219.826087 269.913043-25.043478c8.347826 0 16.695652-8.347826 19.478261-16.695652 2.782609-8.347826 0-16.695652-8.347826-22.26087L33.88599 5.565217C31.103382 2.782609 28.320773 0 22.755556 0z" fill="#CCCCCC" /></svg>';
		svg = svg.replace(/fill:#06CEAE/g, `fill:${color}`);
		return 'data:image/svg+xml;base64,' + convertBase64(svg);
	}

	static locationCursor(color) {
		let svg =
			'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="icon" x="0px" y="0px" width="36px" height="36px" viewBox="0 0 1034 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M76.980575 612.28866s-2.639175 0 0 0c-5.278351-2.639175-10.556701-5.278351-10.556701-7.917526L11.001194 21.113402c0-2.639175 2.639175-7.917526 5.27835-10.556701H21.557895c2.639175 0 5.278351 0 5.27835 2.639175l475.051547 337.814433c2.639175 2.639175 5.278351 7.917526 2.639175 10.556701 0 5.278351-5.278351 7.917526-7.917526 7.917526l-261.27835 26.391753-153.072165 213.773196s-2.639175 2.639175-5.278351 2.639175z"  /><path d="M21.557895 21.113402l475.051546 337.814433-263.917526 26.391753L76.980575 601.731959 21.557895 21.113402m0-21.113402c-2.639175 0-7.917526 0-10.556701 2.639175-7.917526 2.639175-10.556701 10.556701-10.556701 18.474227l55.42268 580.618557c0 7.917526 5.278351 15.835052 15.835052 18.474227h5.27835c5.278351 0 13.195876-2.639175 15.835052-7.917526l150.432989-208.494846 256-23.752577c7.917526 0 15.835052-7.917526 18.474227-15.835051 2.639175-7.917526 0-15.835052-7.917526-21.113402L32.114596 5.278351C29.475421 2.639175 26.836245 0 21.557895 0z" fill="#CCCCCC" /><path d="M979.578513 456.57732c0 81.814433-108.206186 221.690722-166.268041 295.587628-15.835052 21.113402-50.14433 21.113402-65.979381 0-55.42268-73.896907-166.268041-213.773196-166.268042-295.587628 0-110.845361 89.731959-197.938144 197.938145-197.938145s200.57732 89.731959 200.577319 197.938145z" fill="#DDDDDD" /><path d="M779.001194 775.917526c-15.835052 0-29.030928-7.917526-39.587629-18.474227l-5.278351-7.917526c-60.701031-79.175258-160.989691-211.134021-160.98969-290.309278 0-113.484536 92.371134-205.85567 205.85567-205.85567s205.85567 92.371134 205.85567 205.85567c0 81.814433-100.28866 213.773196-160.989691 290.309278l-5.27835 7.917526c-10.556701 10.556701-23.752577 18.474227-39.587629 18.474227z m0-512c-105.56701 0-192.659794 87.092784-192.659794 192.659794 0 76.536082 102.927835 211.134021 158.350515 282.391752l5.278351 7.917526c13.195876 18.474227 42.226804 18.474227 55.42268 0l5.278351-7.917526c55.42268-71.257732 158.350515-205.85567 158.350515-282.391752 2.639175-105.56701-84.453608-192.659794-190.020618-192.659794z" fill="#DDDDDD" /><path d="M779.001194 446.020619m-81.814433 0a81.814433 81.814433 0 1 0 163.628866 0 81.814433 81.814433 0 1 0-163.628866 0Z" fill="#DDDDDD" /><path d="M779.001194 535.752577c-50.14433 0-89.731959-39.587629-89.731959-89.731958s39.587629-89.731959 89.731959-89.731959 89.731959 39.587629 89.731958 89.731959-39.587629 89.731959-89.731958 89.731958z m0-166.268041c-42.226804 0-76.536082 34.309278-76.536083 76.536083 0 42.226804 34.309278 76.536082 76.536083 76.536082s76.536082-34.309278 76.536082-76.536082c0-42.226804-34.309278-76.536082-76.536082-76.536083z" fill="#DDDDDD" /><path d="M779.001194 794.391753c-21.113402 0-42.226804-10.556701-52.783505-26.391753l-5.278351-7.917526c-79.175258-105.56701-166.268041-221.690722-166.268041-303.505154 0-124.041237 100.28866-224.329897 224.329897-224.329897s224.329897 100.28866 224.329897 224.329897c0 87.092784-102.927835 221.690722-166.268042 303.505154l-5.27835 7.917526c-10.556701 18.474227-31.670103 26.391753-52.783505 26.391753z m0-509.360825c-95.010309 0-171.546392 76.536082-171.546392 171.546392 0 68.618557 105.56701 205.85567 155.71134 271.835051l5.278351 7.917526c5.278351 5.278351 10.556701 5.278351 13.195876 5.27835 2.639175 0 7.917526 0 13.195876-5.27835l5.278351-7.917526c50.14433-65.979381 155.71134-200.57732 155.71134-271.835051-2.639175-95.010309-81.814433-171.546392-176.824742-171.546392z"  /><path d="M779.001194 802.309278c-23.752577 0-44.865979-10.556701-58.061856-29.030927l-5.27835-7.917526c-81.814433-105.56701-166.268041-224.329897-166.268042-308.783505 0-126.680412 102.927835-232.247423 232.247423-232.247423 126.680412 0 232.247423 102.927835 232.247423 232.247423 0 89.731959-105.56701 226.969072-166.268042 308.783505l-7.917525 7.917526c-15.835052 18.474227-36.948454 29.030928-60.701031 29.030927z m0-562.14433c-121.402062 0-219.051546 97.649485-219.051547 219.051547 0 79.175258 84.453608 195.298969 163.628866 300.865979l5.278351 7.917526c10.556701 15.835052 29.030928 23.752577 47.505154 23.752577s36.948454-7.917526 47.505155-23.752577l5.278351-7.917526c60.701031-79.175258 163.628866-213.773196 163.628866-298.226804 5.278351-124.041237-92.371134-221.690722-213.773196-221.690722z m0 509.360825c-5.278351 0-10.556701 0-18.474227-7.917526l-2.639175-7.917525C707.743462 667.71134 602.176451 530.474227 602.176451 459.216495c0-97.649485 79.175258-179.463918 179.463918-179.463918 97.649485 0 179.463918 79.175258 179.463917 179.463918 0 71.257732-105.56701 208.494845-155.71134 274.474227l-5.27835 7.917525c-7.917526 5.278351-15.835052 7.917526-21.113402 7.917526z m0-456.577319c-92.371134 0-166.268041 73.896907-166.268042 166.268041 0 68.618557 102.927835 203.216495 153.072165 266.556701l5.278351 7.917526c2.639175 2.639175 5.278351 2.639175 7.917526 2.639175 2.639175 0 5.278351 0 7.917525-2.639175l5.278351-7.917526c50.14433-65.979381 153.072165-200.57732 153.072165-266.556701 0-92.371134-73.896907-166.268041-166.268041-166.268041z" fill="#DDDDDD" /><path d="M779.001194 554.226804c-60.701031 0-108.206186-50.14433-108.206186-108.206185s50.14433-108.206186 108.206186-108.206186c60.701031 0 108.206186 50.14433 108.206185 108.206186s-47.505155 108.206186-108.206185 108.206185z m0-166.268041c-31.670103 0-55.42268 26.391753-55.422681 55.42268s26.391753 55.42268 55.422681 55.422681c31.670103 0 55.42268-26.391753 55.42268-55.422681s-23.752577-55.42268-55.42268-55.42268z"  /><path d="M779.001194 562.14433c-63.340206 0-116.123711-52.783505-116.123712-116.123711s52.783505-116.123711 116.123712-116.123712c63.340206 0 116.123711 52.783505 116.123711 116.123712s-52.783505 116.123711-116.123711 116.123711z m0-219.051546c-55.42268 0-102.927835 44.865979-102.927835 102.927835s44.865979 102.927835 102.927835 102.927835 102.927835-44.865979 102.927835-102.927835-44.865979-102.927835-102.927835-102.927835z m0 166.268041c-34.309278 0-63.340206-29.030928-63.340206-63.340206s29.030928-63.340206 63.340206-63.340207 63.340206 29.030928 63.340206 63.340207-29.030928 63.340206-63.340206 63.340206z m0-113.484536c-26.391753 0-50.14433 21.113402-50.14433 50.14433s21.113402 50.14433 50.14433 50.144329c26.391753 0 50.14433-21.113402 50.14433-50.144329s-21.113402-50.14433-50.14433-50.14433z" fill="#DDDDDD" /></svg>';
		svg = svg.replace(/fill:#06CEAE/g, `fill:${color}`);
		return 'data:image/svg+xml;base64,' + convertBase64(svg);
	}

	static elevationCursor(color) {
		let svg =
			'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="icon" x="0px" y="0px" width="36px" height="36px" viewBox="0 0 1045 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M891.957895 821.894737h-215.578948c-16.168421 0-26.947368-10.778947-26.947368-26.947369s10.778947-26.947368 26.947368-26.947368h215.578948c16.168421 0 26.947368 10.778947 26.947368 26.947368s-10.778947 26.947368-26.947368 26.947369z"  /><path d="M891.957895 827.284211h-215.578948c-18.863158 0-32.336842-16.168421-32.336842-32.336843s16.168421-32.336842 32.336842-32.336842h215.578948c18.863158 0 32.336842 16.168421 32.336842 32.336842s-13.473684 32.336842-32.336842 32.336843z m-215.578948-53.894737c-10.778947 0-21.557895 8.084211-21.557894 21.557894s8.084211 21.557895 21.557894 21.557895h215.578948c10.778947 0 21.557895-8.084211 21.557894-21.557895s-8.084211-21.557895-21.557894-21.557894h-215.578948z" fill="#DDDDDD" /><path d="M797.642105 735.663158h-26.947368v-80.842105h26.947368v80.842105z m0-134.736842h-26.947368v-80.842105h26.947368v80.842105z m0-134.736842h-26.947368v-80.842106h26.947368v80.842106z m0-134.736842h-26.947368v-80.842106h26.947368v80.842106z"  /><path d="M805.726316 741.052632h-40.421053V646.736842h40.421053v94.31579z m-26.947369-13.473685h13.473685v-67.368421h-13.473685V727.578947z m26.947369-121.263158h-40.421053V512h40.421053v94.315789z m-26.947369-13.473684h13.473685v-67.368421h-13.473685V592.842105z m26.947369-121.263158h-40.421053V377.263158h40.421053v94.315789z m-26.947369-13.473684h13.473685v-67.368421h-13.473685V458.105263z m26.947369-121.263158h-40.421053V242.526316h40.421053v94.315789z m-26.947369-13.473684h13.473685V256h-13.473685V323.368421z" fill="#DDDDDD" /><path d="M730.273684 167.073684h107.789474v107.789474h-107.789474z" fill="#DDDDDD" /><path d="M865.010526 301.810526h-161.68421v-161.68421h161.68421v161.68421z m-107.789473-53.894737h53.894736v-53.894736h-53.894736v53.894736z"  /><path d="M873.094737 307.2h-175.157895V132.042105h175.157895v175.157895z m-161.684211-13.473684h148.210527V145.515789h-148.210527v148.210527z m107.789474-40.421053h-67.368421V185.936842h67.368421v67.368421z m-53.894737-13.473684h40.421053V199.410526h-40.421053v40.421053z" fill="#DDDDDD" /><path d="M78.147368 657.515789s-2.694737 0 0 0c-5.389474-2.694737-10.778947-5.389474-10.778947-8.08421l-56.589474-592.842105c0-2.694737 2.694737-8.084211 5.389474-10.778948H21.557895c2.694737 0 5.389474 0 5.389473 2.694737l485.052632 344.926316c2.694737 2.694737 5.389474 8.084211 2.694737 10.778947 0 5.389474-5.389474 8.084211-8.084211 8.084211l-266.778947 26.947368-156.294737 218.273684c0-2.694737-2.694737 0-5.389474 0z"  /><path d="M21.557895 53.894737l485.052631 344.926316-269.473684 26.947368L78.147368 646.736842 21.557895 53.894737m0-18.863158c-2.694737 0-8.084211 0-10.778948 2.694737-8.084211 2.694737-10.778947 10.778947-10.778947 18.863158l56.589474 592.842105c0 8.084211 5.389474 16.168421 16.168421 18.863158h5.389473c5.389474 0 13.473684-2.694737 16.168421-8.084211l153.6-212.88421 261.389474-24.252632c8.084211 0 16.168421-8.084211 18.863158-16.168421 2.694737-8.084211 0-16.168421-8.08421-21.557895L32.336842 37.726316c-2.694737-2.694737-5.389474-2.694737-10.778947-2.694737z" fill="#CCCCCC" /></svg>';
		svg = svg.replace(/fill:#06CEAE/g, `fill:${color}`);
		return 'data:image/svg+xml;base64,' + convertBase64(svg);
	}

	static areaCursor(color) {
		let svg =
			'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="icon" x="0px" y="0px" width="36px" height="36px" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M76.980575 612.28866s-2.639175 0 0 0c-5.278351-2.639175-10.556701-5.278351-10.556701-7.917526L11.001194 21.113402c0-2.639175 2.639175-7.917526 5.27835-10.556701H21.557895c2.639175 0 5.278351 0 5.27835 2.639175l475.051547 337.814433c2.639175 2.639175 5.278351 7.917526 2.639175 10.556701 0 5.278351-5.278351 7.917526-7.917526 7.917526l-261.27835 26.391753-153.072165 213.773196s-2.639175 2.639175-5.278351 2.639175z"  /><path d="M21.557895 21.113402l475.051546 337.814433-263.917526 26.391753L76.980575 601.731959 21.557895 21.113402m0-21.113402c-2.639175 0-7.917526 0-10.556701 2.639175-7.917526 2.639175-10.556701 10.556701-10.556701 18.474227l55.42268 580.618557c0 7.917526 5.278351 15.835052 15.835052 18.474227h5.27835c5.278351 0 13.195876-2.639175 15.835052-7.917526l150.432989-208.494846 256-23.752577c7.917526 0 15.835052-7.917526 18.474227-15.835051 2.639175-7.917526 0-15.835052-7.917526-21.113402L32.114596 5.278351C29.475421 2.639175 26.836245 0 21.557895 0z" fill="#CCCCCC" /><path d="M905.681606 878.845361H311.867173v-5.278351l-15.835051-15.835051L905.681606 253.360825v625.484536z m-567.42268-26.391753h541.030927V316.701031L338.258926 852.453608z"  /><path d="M910.959957 884.123711h-607.01031v-7.917525l-18.474226-18.474227L910.959957 237.525773v646.597938z m-593.814433-13.195876h580.618556V269.195876L303.949647 857.731959l13.195877 13.195876z m567.42268-13.195876H322.423874l564.783505-559.505155v559.505155z m-530.474227-13.195877h517.278351V332.536082L354.093977 844.536082z" fill="#DDDDDD" /><path d="M940.597895 347.869691h-105.567011v-105.567011h105.567011z" fill="#DDDDDD" /><path d="M966.382637 374.762887h-158.350515v-158.350516h158.350515v158.350516z m-105.56701-52.783506h52.783505v-52.783505h-52.783505v52.783505z"  /><path d="M974.300163 380.041237h-171.546392V208.494845h171.546392v171.546392z m-158.350516-13.195876h145.154639V221.690722h-145.154639v145.154639z m105.567011-39.587629h-65.979382V261.278351h65.979382v65.979381z m-52.783506-13.195876h39.587629V274.474227h-39.587629v39.587629zM940.597895 922.391753h-105.567011v-105.567011h105.567011z" fill="#DDDDDD" /><path d="M966.382637 947.463918h-158.350515v-158.350516h158.350515v158.350516z m-105.56701-52.783506h52.783505v-52.783505h-52.783505v52.783505z"  /><path d="M974.300163 955.381443h-171.546392v-171.546391h171.546392v171.546391z m-158.350516-13.195876h145.154639v-145.154639h-145.154639v145.154639z m105.567011-39.587629h-65.979382v-65.979381h65.979382v65.979381z m-52.783506-13.195876h39.587629v-39.587629h-39.587629v39.587629z" fill="#DDDDDD" /><path d="M402.760369 922.550103h-105.56701v-105.56701h105.56701z" fill="#DDDDDD" /><path d="M430.63006 947.463918h-158.350516v-158.350516h158.350516v158.350516z m-105.567011-52.783506h52.783506v-52.783505h-52.783506v52.783505z"  /><path d="M435.90841 955.381443H264.362018v-171.546391h171.546392v171.546391z m-158.350515-13.195876h145.154639v-145.154639H277.557895v145.154639z m105.56701-39.587629h-65.979381v-65.979381h65.979381v65.979381z m-52.783505-13.195876h39.587629v-39.587629h-39.587629v39.587629z" fill="#DDDDDD" /></svg>';
		svg = svg.replace(/fill:#06CEAE/g, `fill:${color}`);
		return 'data:image/svg+xml;base64,' + convertBase64(svg);
	}

	static angleCursor(color) {
		let svg =
			'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="icon" x="0px" y="0px" width="36px" height="36px" viewBox="0 0 1042 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M1013.887792 752.164948l-577.979382 2.639176 414.350516-403.793815-36.948454-36.948453-451.298969 451.298969 18.474227 44.865979 633.402062-5.27835z"  /><path d="M375.207379 815.505155l-21.113402-52.783506L813.310472 303.505155l47.505155 47.505154-409.072165 398.515464 570.061855-2.639175V812.865979l-646.597938 2.639176z m-5.27835-50.14433l15.835051 36.948453 622.845361-2.639175V760.082474l-591.175258 2.639175 422.268042-411.71134-26.391753-26.391752-443.381443 440.742268z" fill="#DDDDDD" /><path d="M602.176451 380.041237c-7.917526-10.556701-18.474227-18.474227-26.391752-29.030928l18.474227-18.474227 29.030927 29.030928-21.113402 18.474227z"  /><path d="M602.176451 387.958763l-5.27835-5.278351c-7.917526-10.556701-18.474227-18.474227-26.391753-29.030927l-5.27835-5.278351 29.030928-29.030928 5.27835 5.278351 29.030928 29.030928 5.278351 5.27835-31.670104 29.030928z m-15.835051-36.948454l18.474227 18.474227 10.556701-7.917526-18.474227-18.474226-10.556701 7.917525z" fill="#DDDDDD" /><path d="M699.825936 506.721649c-13.195876-23.752577-29.030928-44.865979-44.865979-65.979381l21.113402-15.835052c15.835052 21.113402 31.670103 44.865979 47.505154 68.618557l-23.752577 13.195876z"  /><path d="M697.186761 517.278351l-2.639176-5.278351c-13.195876-23.752577-29.030928-44.865979-44.865979-65.979381l-5.27835-5.278351 31.670103-23.752577 2.639175 5.27835c15.835052 21.113402 31.670103 44.865979 47.505155 68.618557l2.639175 5.27835-31.670103 21.113403zM662.877482 443.381443c13.195876 18.474227 26.391753 36.948454 36.948454 55.422681l10.556701-7.917526c-13.195876-18.474227-23.752577-39.587629-39.587629-58.061856l-7.917526 10.556701z" fill="#DDDDDD" /><path d="M810.671297 804.948454l-15.835052-79.175258 26.391753-7.917526c7.917526 26.391753 13.195876 52.783505 18.474227 81.814433l-29.030928 5.278351z m-42.226804-153.072165c-10.556701-23.752577-21.113402-50.14433-31.670103-73.896908l23.752577-10.556701c13.195876 23.752577 23.752577 50.14433 31.670103 76.536083l-23.752577 7.917526z"  /><path d="M805.392946 812.865979v-5.27835c-5.278351-26.391753-10.556701-52.783505-15.835051-76.536083l-2.639176-5.27835 36.948454-10.556701 2.639175 5.27835c7.917526 26.391753 13.195876 52.783505 18.474227 81.814433v5.278351l-39.587629 5.27835z m-5.27835-81.814433c5.278351 21.113402 10.556701 44.865979 13.195876 65.979382l13.195876-2.639175c-2.639175-23.752577-7.917526-44.865979-13.195876-65.979382l-13.195876 2.639175z m-34.309279-71.257732l-2.639175-5.27835c-7.917526-23.752577-18.474227-50.14433-31.670103-73.896907l-2.639175-5.278351 34.309278-18.474227 2.639175 5.278351c13.195876 23.752577 23.752577 50.14433 31.670104 76.536082l2.639175 5.278351-34.309279 15.835051z m-21.113402-79.175257c10.556701 21.113402 18.474227 42.226804 26.391753 60.701031l13.195876-5.278351c-7.917526-21.113402-18.474227-42.226804-26.391752-63.340206l-13.195877 7.917526z" fill="#DDDDDD" /><path d="M821.227998 923.71134c0-13.195876 0-26.391753-2.639175-39.587629l26.391752-2.639175c0 13.195876 2.639175 26.391753 2.639175 39.587629l-26.391752 2.639175z"  /><path d="M815.949647 931.628866v-5.278351c0-13.195876 0-26.391753-2.639175-39.587628v-5.278351l39.587629-2.639175v5.27835c0 13.195876 2.639175 26.391753 2.639175 39.587629v5.278351l-39.587629 2.639175z m10.556701-39.587629v26.391753h13.195877v-26.391753h-13.195877z" fill="#DDDDDD" /><path d="M346.176451 720.494845h105.567011v105.567011h-105.567011z" fill="#DDDDDD" /><path d="M478.135214 852.453608h-158.350515v-158.350515h158.350515v158.350515z m-105.56701-52.783505h52.783505v-52.783505h-52.783505v52.783505z"  /><path d="M483.413565 860.371134H311.867173v-171.546392h171.546392v171.546392z m-158.350516-13.195876H470.217689v-145.154639h-145.15464v145.154639z m105.567011-39.587629H364.650678v-65.979382h65.979382v65.979382z m-52.783505-13.195876H417.434183v-39.587629h-39.587628v39.587629z" fill="#DDDDDD" /><path d="M76.980575 612.28866s-2.639175 0 0 0c-5.278351-2.639175-10.556701-5.278351-10.556701-7.917526L11.001194 21.113402c0-2.639175 2.639175-7.917526 5.27835-10.556701H21.557895c2.639175 0 5.278351 0 5.27835 2.639175l475.051547 337.814433c2.639175 2.639175 5.278351 7.917526 2.639175 10.556701 0 5.278351-5.278351 7.917526-7.917526 7.917526l-261.27835 26.391753-153.072165 213.773196s-2.639175 2.639175-5.278351 2.639175z"  /><path d="M21.557895 21.113402l475.051546 337.814433-263.917526 26.391753L76.980575 601.731959 21.557895 21.113402m0-21.113402c-2.639175 0-7.917526 0-10.556701 2.639175-7.917526 2.639175-10.556701 10.556701-10.556701 18.474227l55.42268 580.618557c0 7.917526 5.278351 15.835052 15.835052 18.474227h5.27835c5.278351 0 13.195876-2.639175 15.835052-7.917526l150.432989-208.494846 256-23.752577c7.917526 0 15.835052-7.917526 18.474227-15.835051 2.639175-7.917526 0-15.835052-7.917526-21.113402L32.114596 5.278351C29.475421 2.639175 26.836245 0 21.557895 0z" fill="#CCCCCC" /></svg>';
		svg = svg.replace(/fill:#06CEAE/g, `fill:${color}`);
		return 'data:image/svg+xml;base64,' + convertBase64(svg);
	}

	static clip(color) {
		let svg =
			'<?xml version="1.0" encoding="utf-8"?><svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 38 38" width="40" height="40" style="enable-background:new 0 0 38 38;" xml:space="preserve"><style type="text/css">.st6{fill:#CCCCCC;}.st291{fill-rule:evenodd;clip-rule:evenodd;}</style><path class="st291" d="M19,15.4L19,15.4c0.6,0,1-0.4,1-1V8c0-0.6-0.4-1-1-1h0c-0.6,0-1,0.4-1,1v6.4C18,15,18.5,15.4,19,15.4z"/><path class="st6" d="M19,15.7c-0.7,0-1.2-0.6-1.2-1.2V8c0-0.7,0.6-1.2,1.2-1.2s1.2,0.6,1.2,1.2v6.4C20.3,15.1,19.7,15.7,19,15.7zM19,7.2c-0.4,0-0.8,0.3-0.8,0.8v6.4c0,0.4,0.3,0.8,0.8,0.8s0.8-0.3,0.8-0.8V8C19.8,7.6,19.4,7.2,19,7.2z"/><path class="st291" d="M15.4,19L15.4,19c0-0.6-0.4-1-1-1H8c-0.6,0-1,0.4-1,1v0c0,0.6,0.4,1,1,1h6.4C15,20,15.4,19.5,15.4,19z"/><path class="st6" d="M14.4,20.2H8c-0.7,0-1.2-0.6-1.2-1.2s0.6-1.2,1.2-1.2h6.4c0.7,0,1.2,0.6,1.2,1.2S15.1,20.2,14.4,20.2zM8,18.2c-0.4,0-0.8,0.3-0.8,0.8s0.3,0.8,0.8,0.8h6.4c0.4,0,0.8-0.3,0.8-0.8s-0.3-0.8-0.8-0.8H8z"/><path class="st291" d="M19,22.6L19,22.6c-0.6,0-1,0.4-1,1V30c0,0.6,0.4,1,1,1h0c0.6,0,1-0.4,1-1v-6.4C20,23,19.5,22.6,19,22.6z"/><path class="st6" d="M19,31.2c-0.7,0-1.2-0.6-1.2-1.2v-6.4c0-0.7,0.6-1.2,1.2-1.2s1.2,0.6,1.2,1.2V30C20.2,30.7,19.7,31.2,19,31.2z M19,22.8c-0.4,0-0.8,0.3-0.8,0.8V30c0,0.4,0.3,0.8,0.8,0.8s0.8-0.3,0.8-0.8v-6.4\tC19.7,23.2,19.4,22.8,19,22.8z"/><path class="st291" d="M22.6,19L22.6,19c0,0.6,0.4,1,1,1H30c0.6,0,1-0.4,1-1v0c0-0.6-0.4-1-1-1h-6.4C23,18,22.6,18.5,22.6,19z"/><path class="st6" d="M30,20.3h-6.4c-0.7,0-1.2-0.6-1.2-1.2s0.6-1.2,1.2-1.2H30c0.7,0,1.2,0.6,1.2,1.2S30.7,20.3,30,20.3z M23.6,18.3c-0.4,0-0.8,0.3-0.8,0.8s0.3,0.8,0.8,0.8H30c0.4,0,0.8-0.3,0.8-0.8s-0.3-0.8-0.8-0.8H23.6z"/><circle class="st291" cx="19" cy="19" r="1"/><path class="st6" d="M19,20.2c-0.7,0-1.2-0.6-1.2-1.2s0.6-1.2,1.2-1.2s1.2,0.6,1.2,1.2S19.7,20.2,19,20.2z M19,18.2c-0.4,0-0.8,0.3-0.8,0.8s0.3,0.8,0.8,0.8s0.8-0.3,0.8-0.8S19.4,18.2,19,18.2z"/></svg>\n';
		svg = svg.replace(/fill:#06CEAE/g, `fill:${color}`);
		return 'data:image/svg+xml;base64,' + convertBase64(svg);
	}

	static labelText(color) {
		let svg =
			'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="icon" x="0px" y="0px" width="36px" height="36px" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M630.844804 869.087179c-21.005128 0-36.758974-15.753846-36.758974-36.758974v-225.805128H499.562753c-21.005128 0-36.758974-15.753846-36.758974-36.758974s15.753846-36.758974 36.758974-36.758975h262.564103c21.005128 0 36.758974 15.753846 36.758974 36.758975s-15.753846 36.758974-36.758974 36.758974h-94.523077v225.805128c0 18.379487-15.753846 36.758974-36.758975 36.758974z"  /><path d="M762.126856 543.507692c15.753846 0 26.25641 10.502564 26.25641 26.256411s-10.502564 26.25641-26.25641 26.25641h-105.025641v236.307692c0 15.753846-10.502564 26.25641-26.256411 26.25641s-26.25641-10.502564-26.25641-26.25641v-236.307692h-105.025641c-15.753846 0-26.25641-10.502564-26.25641-26.25641s10.502564-26.25641 26.25641-26.256411h262.564103m0-21.005128H499.562753c-26.25641 0-47.261538 21.005128-47.261538 47.261539s21.005128 47.261538 47.261538 47.261538h84.020513v215.302564c0 26.25641 21.005128 47.261538 47.261538 47.261539s47.261538-21.005128 47.261539-47.261539v-215.302564H762.126856c26.25641 0 47.261538-21.005128 47.261538-47.261538s-21.005128-47.261538-47.261538-47.261539z" fill="#DDDDDD" /><path d="M82.08583 617.025641H79.460189c-5.251282-2.625641-7.876923-5.251282-10.502564-10.502564L13.819163 26.25641c0-5.251282 2.625641-10.502564 5.251282-13.128205 2.625641 0 5.251282-2.625641 5.251282-2.625641 2.625641 0 5.251282 0 7.876923 2.625641l472.615385 336.082051c5.251282 2.625641 5.251282 7.876923 5.251282 13.128206-2.625641 5.251282-5.251282 7.876923-10.502564 10.502564l-257.31282 26.25641-149.661539 210.051282c-2.625641 5.251282-7.876923 7.876923-10.502564 7.876923z"  /><path d="M26.947368 26.25641l472.615385 336.082052-262.564103 26.25641L82.08583 603.897436 26.947368 26.25641m0-26.25641c-5.251282 0-7.876923 0-13.128205 2.625641-7.876923 5.251282-13.128205 15.753846-13.128205 26.25641l55.138462 577.641026c0 10.502564 7.876923 21.005128 18.379487 23.630769h7.876923c7.876923 0 15.753846-5.251282 21.005128-10.502564l147.035898-204.8 252.061538-23.630769c10.502564 0 21.005128-7.876923 23.630769-18.379487 2.625641-10.502564 0-21.005128-10.502564-28.882052L42.701215 5.251282C37.449933 2.625641 32.19865 0 26.947368 0z" fill="#CCCCCC" /></svg>';
		svg = svg.replace(/fill:#06CEAE/g, `fill:${color}`);
		return 'data:image/svg+xml;base64,' + convertBase64(svg);
	}

	static labelLocation(color) {
		let svg =
			'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="icon" x="0px" y="0px" width="36px" height="36px" viewBox="0 0 1034 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M76.980575 612.28866s-2.639175 0 0 0c-5.278351-2.639175-10.556701-5.278351-10.556701-7.917526L11.001194 21.113402c0-2.639175 2.639175-7.917526 5.27835-10.556701H21.557895c2.639175 0 5.278351 0 5.27835 2.639175l475.051547 337.814433c2.639175 2.639175 5.278351 7.917526 2.639175 10.556701 0 5.278351-5.278351 7.917526-7.917526 7.917526l-261.27835 26.391753-153.072165 213.773196s-2.639175 2.639175-5.278351 2.639175z"  /><path d="M21.557895 21.113402l475.051546 337.814433-263.917526 26.391753L76.980575 601.731959 21.557895 21.113402m0-21.113402c-2.639175 0-7.917526 0-10.556701 2.639175-7.917526 2.639175-10.556701 10.556701-10.556701 18.474227l55.42268 580.618557c0 7.917526 5.278351 15.835052 15.835052 18.474227h5.27835c5.278351 0 13.195876-2.639175 15.835052-7.917526l150.432989-208.494846 256-23.752577c7.917526 0 15.835052-7.917526 18.474227-15.835051 2.639175-7.917526 0-15.835052-7.917526-21.113402L32.114596 5.278351C29.475421 2.639175 26.836245 0 21.557895 0z" fill="#CCCCCC" /><path d="M979.578513 456.57732c0 81.814433-108.206186 221.690722-166.268041 295.587628-15.835052 21.113402-50.14433 21.113402-65.979381 0-55.42268-73.896907-166.268041-213.773196-166.268042-295.587628 0-110.845361 89.731959-197.938144 197.938145-197.938145s200.57732 89.731959 200.577319 197.938145z" fill="#DDDDDD" /><path d="M779.001194 775.917526c-15.835052 0-29.030928-7.917526-39.587629-18.474227l-5.278351-7.917526c-60.701031-79.175258-160.989691-211.134021-160.98969-290.309278 0-113.484536 92.371134-205.85567 205.85567-205.85567s205.85567 92.371134 205.85567 205.85567c0 81.814433-100.28866 213.773196-160.989691 290.309278l-5.27835 7.917526c-10.556701 10.556701-23.752577 18.474227-39.587629 18.474227z m0-512c-105.56701 0-192.659794 87.092784-192.659794 192.659794 0 76.536082 102.927835 211.134021 158.350515 282.391752l5.278351 7.917526c13.195876 18.474227 42.226804 18.474227 55.42268 0l5.278351-7.917526c55.42268-71.257732 158.350515-205.85567 158.350515-282.391752 2.639175-105.56701-84.453608-192.659794-190.020618-192.659794z" fill="#DDDDDD" /><path d="M779.001194 446.020619m-81.814433 0a81.814433 81.814433 0 1 0 163.628866 0 81.814433 81.814433 0 1 0-163.628866 0Z" fill="#DDDDDD" /><path d="M779.001194 535.752577c-50.14433 0-89.731959-39.587629-89.731959-89.731958s39.587629-89.731959 89.731959-89.731959 89.731959 39.587629 89.731958 89.731959-39.587629 89.731959-89.731958 89.731958z m0-166.268041c-42.226804 0-76.536082 34.309278-76.536083 76.536083 0 42.226804 34.309278 76.536082 76.536083 76.536082s76.536082-34.309278 76.536082-76.536082c0-42.226804-34.309278-76.536082-76.536082-76.536083z" fill="#DDDDDD" /><path d="M779.001194 794.391753c-21.113402 0-42.226804-10.556701-52.783505-26.391753l-5.278351-7.917526c-79.175258-105.56701-166.268041-221.690722-166.268041-303.505154 0-124.041237 100.28866-224.329897 224.329897-224.329897s224.329897 100.28866 224.329897 224.329897c0 87.092784-102.927835 221.690722-166.268042 303.505154l-5.27835 7.917526c-10.556701 18.474227-31.670103 26.391753-52.783505 26.391753z m0-509.360825c-95.010309 0-171.546392 76.536082-171.546392 171.546392 0 68.618557 105.56701 205.85567 155.71134 271.835051l5.278351 7.917526c5.278351 5.278351 10.556701 5.278351 13.195876 5.27835 2.639175 0 7.917526 0 13.195876-5.27835l5.278351-7.917526c50.14433-65.979381 155.71134-200.57732 155.71134-271.835051-2.639175-95.010309-81.814433-171.546392-176.824742-171.546392z"  /><path d="M779.001194 802.309278c-23.752577 0-44.865979-10.556701-58.061856-29.030927l-5.27835-7.917526c-81.814433-105.56701-166.268041-224.329897-166.268042-308.783505 0-126.680412 102.927835-232.247423 232.247423-232.247423 126.680412 0 232.247423 102.927835 232.247423 232.247423 0 89.731959-105.56701 226.969072-166.268042 308.783505l-7.917525 7.917526c-15.835052 18.474227-36.948454 29.030928-60.701031 29.030927z m0-562.14433c-121.402062 0-219.051546 97.649485-219.051547 219.051547 0 79.175258 84.453608 195.298969 163.628866 300.865979l5.278351 7.917526c10.556701 15.835052 29.030928 23.752577 47.505154 23.752577s36.948454-7.917526 47.505155-23.752577l5.278351-7.917526c60.701031-79.175258 163.628866-213.773196 163.628866-298.226804 5.278351-124.041237-92.371134-221.690722-213.773196-221.690722z m0 509.360825c-5.278351 0-10.556701 0-18.474227-7.917526l-2.639175-7.917525C707.743462 667.71134 602.176451 530.474227 602.176451 459.216495c0-97.649485 79.175258-179.463918 179.463918-179.463918 97.649485 0 179.463918 79.175258 179.463917 179.463918 0 71.257732-105.56701 208.494845-155.71134 274.474227l-5.27835 7.917525c-7.917526 5.278351-15.835052 7.917526-21.113402 7.917526z m0-456.577319c-92.371134 0-166.268041 73.896907-166.268042 166.268041 0 68.618557 102.927835 203.216495 153.072165 266.556701l5.278351 7.917526c2.639175 2.639175 5.278351 2.639175 7.917526 2.639175 2.639175 0 5.278351 0 7.917525-2.639175l5.278351-7.917526c50.14433-65.979381 153.072165-200.57732 153.072165-266.556701 0-92.371134-73.896907-166.268041-166.268041-166.268041z" fill="#DDDDDD" /><path d="M779.001194 554.226804c-60.701031 0-108.206186-50.14433-108.206186-108.206185s50.14433-108.206186 108.206186-108.206186c60.701031 0 108.206186 50.14433 108.206185 108.206186s-47.505155 108.206186-108.206185 108.206185z m0-166.268041c-31.670103 0-55.42268 26.391753-55.422681 55.42268s26.391753 55.42268 55.422681 55.422681c31.670103 0 55.42268-26.391753 55.42268-55.422681s-23.752577-55.42268-55.42268-55.42268z"  /><path d="M779.001194 562.14433c-63.340206 0-116.123711-52.783505-116.123712-116.123711s52.783505-116.123711 116.123712-116.123712c63.340206 0 116.123711 52.783505 116.123711 116.123712s-52.783505 116.123711-116.123711 116.123711z m0-219.051546c-55.42268 0-102.927835 44.865979-102.927835 102.927835s44.865979 102.927835 102.927835 102.927835 102.927835-44.865979 102.927835-102.927835-44.865979-102.927835-102.927835-102.927835z m0 166.268041c-34.309278 0-63.340206-29.030928-63.340206-63.340206s29.030928-63.340206 63.340206-63.340207 63.340206 29.030928 63.340206 63.340207-29.030928 63.340206-63.340206 63.340206z m0-113.484536c-26.391753 0-50.14433 21.113402-50.14433 50.14433s21.113402 50.14433 50.14433 50.144329c26.391753 0 50.14433-21.113402 50.14433-50.144329s-21.113402-50.14433-50.14433-50.14433z" fill="#DDDDDD" /></svg>';
		svg = svg.replace(/fill:#06CEAE/g, `fill:${color}`);
		return 'data:image/svg+xml;base64,' + convertBase64(svg);
	}

	static labelElevation(color) {
		let svg =
			'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="icon" x="0px" y="0px" width="36px" height="36px" viewBox="0 0 1045 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M891.957895 821.894737h-215.578948c-16.168421 0-26.947368-10.778947-26.947368-26.947369s10.778947-26.947368 26.947368-26.947368h215.578948c16.168421 0 26.947368 10.778947 26.947368 26.947368s-10.778947 26.947368-26.947368 26.947369z"  /><path d="M891.957895 827.284211h-215.578948c-18.863158 0-32.336842-16.168421-32.336842-32.336843s16.168421-32.336842 32.336842-32.336842h215.578948c18.863158 0 32.336842 16.168421 32.336842 32.336842s-13.473684 32.336842-32.336842 32.336843z m-215.578948-53.894737c-10.778947 0-21.557895 8.084211-21.557894 21.557894s8.084211 21.557895 21.557894 21.557895h215.578948c10.778947 0 21.557895-8.084211 21.557894-21.557895s-8.084211-21.557895-21.557894-21.557894h-215.578948z" fill="#DDDDDD" /><path d="M797.642105 735.663158h-26.947368v-80.842105h26.947368v80.842105z m0-134.736842h-26.947368v-80.842105h26.947368v80.842105z m0-134.736842h-26.947368v-80.842106h26.947368v80.842106z m0-134.736842h-26.947368v-80.842106h26.947368v80.842106z"  /><path d="M805.726316 741.052632h-40.421053V646.736842h40.421053v94.31579z m-26.947369-13.473685h13.473685v-67.368421h-13.473685V727.578947z m26.947369-121.263158h-40.421053V512h40.421053v94.315789z m-26.947369-13.473684h13.473685v-67.368421h-13.473685V592.842105z m26.947369-121.263158h-40.421053V377.263158h40.421053v94.315789z m-26.947369-13.473684h13.473685v-67.368421h-13.473685V458.105263z m26.947369-121.263158h-40.421053V242.526316h40.421053v94.315789z m-26.947369-13.473684h13.473685V256h-13.473685V323.368421z" fill="#DDDDDD" /><path d="M730.273684 167.073684h107.789474v107.789474h-107.789474z" fill="#DDDDDD" /><path d="M865.010526 301.810526h-161.68421v-161.68421h161.68421v161.68421z m-107.789473-53.894737h53.894736v-53.894736h-53.894736v53.894736z"  /><path d="M873.094737 307.2h-175.157895V132.042105h175.157895v175.157895z m-161.684211-13.473684h148.210527V145.515789h-148.210527v148.210527z m107.789474-40.421053h-67.368421V185.936842h67.368421v67.368421z m-53.894737-13.473684h40.421053V199.410526h-40.421053v40.421053z" fill="#DDDDDD" /><path d="M78.147368 657.515789s-2.694737 0 0 0c-5.389474-2.694737-10.778947-5.389474-10.778947-8.08421l-56.589474-592.842105c0-2.694737 2.694737-8.084211 5.389474-10.778948H21.557895c2.694737 0 5.389474 0 5.389473 2.694737l485.052632 344.926316c2.694737 2.694737 5.389474 8.084211 2.694737 10.778947 0 5.389474-5.389474 8.084211-8.084211 8.084211l-266.778947 26.947368-156.294737 218.273684c0-2.694737-2.694737 0-5.389474 0z"  /><path d="M21.557895 53.894737l485.052631 344.926316-269.473684 26.947368L78.147368 646.736842 21.557895 53.894737m0-18.863158c-2.694737 0-8.084211 0-10.778948 2.694737-8.084211 2.694737-10.778947 10.778947-10.778947 18.863158l56.589474 592.842105c0 8.084211 5.389474 16.168421 16.168421 18.863158h5.389473c5.389474 0 13.473684-2.694737 16.168421-8.084211l153.6-212.88421 261.389474-24.252632c8.084211 0 16.168421-8.084211 18.863158-16.168421 2.694737-8.084211 0-16.168421-8.08421-21.557895L32.336842 37.726316c-2.694737-2.694737-5.389474-2.694737-10.778947-2.694737z" fill="#CCCCCC" /></svg>';
		svg = svg.replace(/fill:#06CEAE/g, `fill:${color}`);
		return 'data:image/svg+xml;base64,' + convertBase64(svg);
	}

	static labelDistance(color) {
		let svg =
			'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="icon" x="0px" y="0px" width="36px" height="36px" viewBox="0 0 1035 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M326.059903 818.086957v-222.608696c0-16.695652 11.130435-27.826087 27.826087-27.826087s27.826087 11.130435 27.826087 27.826087v222.608696c0 16.695652-11.130435 27.826087-27.826087 27.826086s-27.826087-13.913043-27.826087-27.826086z"  /><path d="M353.88599 851.478261c-19.478261 0-33.391304-16.695652-33.391304-33.391304v-222.608696c0-19.478261 16.695652-33.391304 33.391304-33.391304s33.391304 16.695652 33.391305 33.391304v222.608696c2.782609 16.695652-13.913043 33.391304-33.391305 33.391304z m0-278.26087c-11.130435 0-22.26087 8.347826-22.260869 22.26087v222.608696c0 11.130435 8.347826 22.26087 22.260869 22.260869s22.26087-8.347826 22.26087-22.260869v-222.608696c0-13.913043-11.130435-22.26087-22.26087-22.26087z" fill="#DDDDDD" /><path d="M409.538164 720.695652v-27.826087h83.478261v27.826087h-83.478261z m139.130435 0v-27.826087h83.478261v27.826087h-83.478261z m139.130435 0v-27.826087h83.478261v27.826087h-83.478261z m139.130435 0v-27.826087h83.47826v27.826087h-83.47826z"  /><path d="M918.755556 726.26087h-97.391305v-41.739131h97.391305v41.739131z m-83.478261-13.913044h69.565217v-13.913043h-69.565217v13.913043z m-55.652174 13.913044h-97.391305v-41.739131h97.391305v41.739131z m-83.478261-13.913044h69.565217v-13.913043h-69.565217v13.913043z m-55.652174 13.913044h-97.391304v-41.739131h97.391304v41.739131z m-83.478261-13.913044h69.565218v-13.913043h-69.565218v13.913043z m-55.652174 13.913044h-97.391304v-41.739131h97.391304v41.739131z m-83.478261-13.913044h69.565218v-13.913043h-69.565218v13.913043z" fill="#DDDDDD" /><path d="M865.88599 651.130435h111.304348v111.304348h-111.304348z" fill="#DDDDDD" /><path d="M1005.016425 790.26087h-166.956522v-166.956522h166.956522v166.956522z m-111.304348-55.652174h55.652174v-55.652174h-55.652174v55.652174z"  /><path d="M1013.364251 795.826087h-180.869565v-180.869565h180.869565v180.869565z m-166.956522-13.913044h153.043479v-153.043478h-153.043479v153.043478z m111.304348-41.73913h-69.565217v-69.565217h69.565217v69.565217z m-55.652174-13.913043h41.739131v-41.739131h-41.739131v41.739131z" fill="#DDDDDD" /><path d="M81.190338 645.565217s-2.782609 0 0 0c-5.565217-2.782609-11.130435-5.565217-11.130435-8.347826L11.625121 22.26087c0-2.782609 2.782609-8.347826 5.565217-11.130435H22.755556c2.782609 0 5.565217 0 5.565217 2.782608l500.869565 356.173914c2.782609 2.782609 5.565217 8.347826 2.782609 11.130434 0 5.565217-5.565217 8.347826-8.347826 8.347826l-275.478261 27.826087-161.391304 225.391305s-2.782609 2.782609-5.565218 2.782608z"  /><path d="M22.755556 22.26087l500.869565 356.173913-278.26087 27.826087L81.190338 634.434783 22.755556 22.26087m0-22.26087c-2.782609 0-8.347826 0-11.130435 2.782609-8.347826 2.782609-11.130435 11.130435-11.130435 19.478261l58.434783 612.173913c0 8.347826 5.565217 16.695652 16.695652 19.47826h5.565217c5.565217 0 13.913043-2.782609 16.695652-8.347826l158.608696-219.826087 269.913043-25.043478c8.347826 0 16.695652-8.347826 19.478261-16.695652 2.782609-8.347826 0-16.695652-8.347826-22.26087L33.88599 5.565217C31.103382 2.782609 28.320773 0 22.755556 0z" fill="#CCCCCC" /></svg>';
		svg = svg.replace(/fill:#06CEAE/g, `fill:${color}`);
		return 'data:image/svg+xml;base64,' + convertBase64(svg);
	}

	static labelArea(color) {
		let svg =
			'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="icon" x="0px" y="0px" width="36px" height="36px" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M76.980575 612.28866s-2.639175 0 0 0c-5.278351-2.639175-10.556701-5.278351-10.556701-7.917526L11.001194 21.113402c0-2.639175 2.639175-7.917526 5.27835-10.556701H21.557895c2.639175 0 5.278351 0 5.27835 2.639175l475.051547 337.814433c2.639175 2.639175 5.278351 7.917526 2.639175 10.556701 0 5.278351-5.278351 7.917526-7.917526 7.917526l-261.27835 26.391753-153.072165 213.773196s-2.639175 2.639175-5.278351 2.639175z"  /><path d="M21.557895 21.113402l475.051546 337.814433-263.917526 26.391753L76.980575 601.731959 21.557895 21.113402m0-21.113402c-2.639175 0-7.917526 0-10.556701 2.639175-7.917526 2.639175-10.556701 10.556701-10.556701 18.474227l55.42268 580.618557c0 7.917526 5.278351 15.835052 15.835052 18.474227h5.27835c5.278351 0 13.195876-2.639175 15.835052-7.917526l150.432989-208.494846 256-23.752577c7.917526 0 15.835052-7.917526 18.474227-15.835051 2.639175-7.917526 0-15.835052-7.917526-21.113402L32.114596 5.278351C29.475421 2.639175 26.836245 0 21.557895 0z" fill="#CCCCCC" /><path d="M905.681606 878.845361H311.867173v-5.278351l-15.835051-15.835051L905.681606 253.360825v625.484536z m-567.42268-26.391753h541.030927V316.701031L338.258926 852.453608z"  /><path d="M910.959957 884.123711h-607.01031v-7.917525l-18.474226-18.474227L910.959957 237.525773v646.597938z m-593.814433-13.195876h580.618556V269.195876L303.949647 857.731959l13.195877 13.195876z m567.42268-13.195876H322.423874l564.783505-559.505155v559.505155z m-530.474227-13.195877h517.278351V332.536082L354.093977 844.536082z" fill="#DDDDDD" /><path d="M940.597895 347.869691h-105.567011v-105.567011h105.567011z" fill="#DDDDDD" /><path d="M966.382637 374.762887h-158.350515v-158.350516h158.350515v158.350516z m-105.56701-52.783506h52.783505v-52.783505h-52.783505v52.783505z"  /><path d="M974.300163 380.041237h-171.546392V208.494845h171.546392v171.546392z m-158.350516-13.195876h145.154639V221.690722h-145.154639v145.154639z m105.567011-39.587629h-65.979382V261.278351h65.979382v65.979381z m-52.783506-13.195876h39.587629V274.474227h-39.587629v39.587629zM940.597895 922.391753h-105.567011v-105.567011h105.567011z" fill="#DDDDDD" /><path d="M966.382637 947.463918h-158.350515v-158.350516h158.350515v158.350516z m-105.56701-52.783506h52.783505v-52.783505h-52.783505v52.783505z"  /><path d="M974.300163 955.381443h-171.546392v-171.546391h171.546392v171.546391z m-158.350516-13.195876h145.154639v-145.154639h-145.154639v145.154639z m105.567011-39.587629h-65.979382v-65.979381h65.979382v65.979381z m-52.783506-13.195876h39.587629v-39.587629h-39.587629v39.587629z" fill="#DDDDDD" /><path d="M402.760369 922.550103h-105.56701v-105.56701h105.56701z" fill="#DDDDDD" /><path d="M430.63006 947.463918h-158.350516v-158.350516h158.350516v158.350516z m-105.567011-52.783506h52.783506v-52.783505h-52.783506v52.783505z"  /><path d="M435.90841 955.381443H264.362018v-171.546391h171.546392v171.546391z m-158.350515-13.195876h145.154639v-145.154639H277.557895v145.154639z m105.56701-39.587629h-65.979381v-65.979381h65.979381v65.979381z m-52.783505-13.195876h39.587629v-39.587629h-39.587629v39.587629z" fill="#DDDDDD" /></svg>';
		svg = svg.replace(/fill:#06CEAE/g, `fill:${color}`);
		return 'data:image/svg+xml;base64,' + convertBase64(svg);
	}

	static labelAngle(color) {
		let svg =
			'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="icon" x="0px" y="0px" width="36px" height="36px" viewBox="0 0 1042 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M1013.887792 752.164948l-577.979382 2.639176 414.350516-403.793815-36.948454-36.948453-451.298969 451.298969 18.474227 44.865979 633.402062-5.27835z"  /><path d="M375.207379 815.505155l-21.113402-52.783506L813.310472 303.505155l47.505155 47.505154-409.072165 398.515464 570.061855-2.639175V812.865979l-646.597938 2.639176z m-5.27835-50.14433l15.835051 36.948453 622.845361-2.639175V760.082474l-591.175258 2.639175 422.268042-411.71134-26.391753-26.391752-443.381443 440.742268z" fill="#DDDDDD" /><path d="M602.176451 380.041237c-7.917526-10.556701-18.474227-18.474227-26.391752-29.030928l18.474227-18.474227 29.030927 29.030928-21.113402 18.474227z"  /><path d="M602.176451 387.958763l-5.27835-5.278351c-7.917526-10.556701-18.474227-18.474227-26.391753-29.030927l-5.27835-5.278351 29.030928-29.030928 5.27835 5.278351 29.030928 29.030928 5.278351 5.27835-31.670104 29.030928z m-15.835051-36.948454l18.474227 18.474227 10.556701-7.917526-18.474227-18.474226-10.556701 7.917525z" fill="#DDDDDD" /><path d="M699.825936 506.721649c-13.195876-23.752577-29.030928-44.865979-44.865979-65.979381l21.113402-15.835052c15.835052 21.113402 31.670103 44.865979 47.505154 68.618557l-23.752577 13.195876z"  /><path d="M697.186761 517.278351l-2.639176-5.278351c-13.195876-23.752577-29.030928-44.865979-44.865979-65.979381l-5.27835-5.278351 31.670103-23.752577 2.639175 5.27835c15.835052 21.113402 31.670103 44.865979 47.505155 68.618557l2.639175 5.27835-31.670103 21.113403zM662.877482 443.381443c13.195876 18.474227 26.391753 36.948454 36.948454 55.422681l10.556701-7.917526c-13.195876-18.474227-23.752577-39.587629-39.587629-58.061856l-7.917526 10.556701z" fill="#DDDDDD" /><path d="M810.671297 804.948454l-15.835052-79.175258 26.391753-7.917526c7.917526 26.391753 13.195876 52.783505 18.474227 81.814433l-29.030928 5.278351z m-42.226804-153.072165c-10.556701-23.752577-21.113402-50.14433-31.670103-73.896908l23.752577-10.556701c13.195876 23.752577 23.752577 50.14433 31.670103 76.536083l-23.752577 7.917526z"  /><path d="M805.392946 812.865979v-5.27835c-5.278351-26.391753-10.556701-52.783505-15.835051-76.536083l-2.639176-5.27835 36.948454-10.556701 2.639175 5.27835c7.917526 26.391753 13.195876 52.783505 18.474227 81.814433v5.278351l-39.587629 5.27835z m-5.27835-81.814433c5.278351 21.113402 10.556701 44.865979 13.195876 65.979382l13.195876-2.639175c-2.639175-23.752577-7.917526-44.865979-13.195876-65.979382l-13.195876 2.639175z m-34.309279-71.257732l-2.639175-5.27835c-7.917526-23.752577-18.474227-50.14433-31.670103-73.896907l-2.639175-5.278351 34.309278-18.474227 2.639175 5.278351c13.195876 23.752577 23.752577 50.14433 31.670104 76.536082l2.639175 5.278351-34.309279 15.835051z m-21.113402-79.175257c10.556701 21.113402 18.474227 42.226804 26.391753 60.701031l13.195876-5.278351c-7.917526-21.113402-18.474227-42.226804-26.391752-63.340206l-13.195877 7.917526z" fill="#DDDDDD" /><path d="M821.227998 923.71134c0-13.195876 0-26.391753-2.639175-39.587629l26.391752-2.639175c0 13.195876 2.639175 26.391753 2.639175 39.587629l-26.391752 2.639175z"  /><path d="M815.949647 931.628866v-5.278351c0-13.195876 0-26.391753-2.639175-39.587628v-5.278351l39.587629-2.639175v5.27835c0 13.195876 2.639175 26.391753 2.639175 39.587629v5.278351l-39.587629 2.639175z m10.556701-39.587629v26.391753h13.195877v-26.391753h-13.195877z" fill="#DDDDDD" /><path d="M346.176451 720.494845h105.567011v105.567011h-105.567011z" fill="#DDDDDD" /><path d="M478.135214 852.453608h-158.350515v-158.350515h158.350515v158.350515z m-105.56701-52.783505h52.783505v-52.783505h-52.783505v52.783505z"  /><path d="M483.413565 860.371134H311.867173v-171.546392h171.546392v171.546392z m-158.350516-13.195876H470.217689v-145.154639h-145.15464v145.154639z m105.567011-39.587629H364.650678v-65.979382h65.979382v65.979382z m-52.783505-13.195876H417.434183v-39.587629h-39.587628v39.587629z" fill="#DDDDDD" /><path d="M76.980575 612.28866s-2.639175 0 0 0c-5.278351-2.639175-10.556701-5.278351-10.556701-7.917526L11.001194 21.113402c0-2.639175 2.639175-7.917526 5.27835-10.556701H21.557895c2.639175 0 5.278351 0 5.27835 2.639175l475.051547 337.814433c2.639175 2.639175 5.278351 7.917526 2.639175 10.556701 0 5.278351-5.278351 7.917526-7.917526 7.917526l-261.27835 26.391753-153.072165 213.773196s-2.639175 2.639175-5.278351 2.639175z"  /><path d="M21.557895 21.113402l475.051546 337.814433-263.917526 26.391753L76.980575 601.731959 21.557895 21.113402m0-21.113402c-2.639175 0-7.917526 0-10.556701 2.639175-7.917526 2.639175-10.556701 10.556701-10.556701 18.474227l55.42268 580.618557c0 7.917526 5.278351 15.835052 15.835052 18.474227h5.27835c5.278351 0 13.195876-2.639175 15.835052-7.917526l150.432989-208.494846 256-23.752577c7.917526 0 15.835052-7.917526 18.474227-15.835051 2.639175-7.917526 0-15.835052-7.917526-21.113402L32.114596 5.278351C29.475421 2.639175 26.836245 0 21.557895 0z" fill="#CCCCCC" /></svg>';
		svg = svg.replace(/fill:#06CEAE/g, `fill:${color}`);
		return 'data:image/svg+xml;base64,' + convertBase64(svg);
	}
}

const convertBase64 = (svg) => window.btoa(unescape(encodeURIComponent(svg)));

export class ToolColor {
	static get color() {
		return VGE.config.color;
	}

	static get themeColor() {
		return VGE.config.primaryColor;
	}

	static get functionalColor() {
		return VGE.config.secondaryColor;
	}

	static get backgroundColor() {
		return VGE.config.backgroundColor;
	}

	/**
	 * 转化 RGB 为 HEX
	 * @param rgb {string}  如：RGB(255,255,255) => #FFFFFF
	 */
	static rgbToHex(rgb) {
		const color = rgb;
		if (!this.isRgb(color)) return color.toString();

		let strHex = '#';
		// 把RGB的3个数值变成数组
		const colorArr = color.replace(/(?:\(|\)|rgb|RGB)*/g, '').split(',');

		// 转成16进制
		colorArr.forEach((item) => {
			let hex = Number(item).toString(16);

			if (hex.length === 1) {
				hex = '0' + hex;
			}

			strHex += hex;
		});

		return strHex;
	}

	/**
	 * 转化 RGBA 为 HEXA
	 * @param rgba {string}  如：RGBA(255,255,255,0.15) => #FFFFFF26
	 */
	static rgbaToHexa(rgba) {
		const color = rgba;
		if (!this.isRgba(color)) return color.toString();

		let strHexa = '#';
		// 把 RGBA 的 4 个数值变成数组
		const colorArr = color.replace(/(?:\(|\)|rgba|RGBA)*/g, '').split(',');

		// 转成16进制
		colorArr.forEach((item, index) => {
			let hex = Math.round((index === 3 ? 255 : 1) * item).toString(16);

			if (hex.length === 1) {
				hex = '0' + hex;
			}

			strHexa += hex;
		});

		return strHexa;
	}

	/**
	 * 转化 HEX 为 RGB
	 * @param hex {string}  如：#FFFFFF => RGB(255,255,255)
	 * @returns {string}
	 */
	static hexToRgb(hex) {
		// 把颜色值变成小写
		let color = hex.toLowerCase();

		if (!this.isHex(color)) return color;

		// 如果只有三位的值，需变成六位，如：#fff => #ffffff
		if (color.length === 4) {
			let colorNew = '#';
			for (let i = 1; i < 4; i += 1) {
				colorNew += color.slice(i, i + 1).concat(color.slice(i, i + 1));
			}
			color = colorNew;
		}
		// 处理六位的颜色值，转为RGB
		const colorChange = [];
		for (let i = 1; i < 7; i += 2) {
			colorChange.push(parseInt('0x' + color.slice(i, i + 2)));
		}
		return 'rgb(' + colorChange.join(',') + ')';
	}

	/**
	 * 转化 HEXA 为 RGBA
	 * @param hexa {string}  如：#FFFFFF16 => RGBA(255,255,255,0.15)
	 * @returns {string}
	 */
	static hexaToRgba(hexa) {
		// 把颜色值变成小写
		let color = hexa.toLowerCase();
		if (!this.isHexa(color)) return color;

		// 如果只有三位的值，需变成八位，如：#ffff => #ffffffff
		if (color.length === 5) {
			let colorNew = '#';
			for (let i = 1; i < 5; i += 1) {
				colorNew += color.slice(i, i + 1).concat(color.slice(i, i + 1));
			}
			color = colorNew;
		}
		// 处理八位的颜色值，转为RGBA
		const colorChange = [];
		for (let i = 1; i < 9; i += 2) {
			const num = parseInt('0x' + color.slice(i, i + 2));
			colorChange.push(
				i < 7 ? num : num % 255 === 0 ? num / 255 : Math.round((num / 255) * 100) / 100
			);
		}
		return 'rgba(' + colorChange.join(',') + ')';
	}

	/**
	 * 颜色值转为浮点类型数组
	 * @param color {string}
	 * @returns {string[]|*}
	 */
	static toFloatArr(color) {
		if (this.isRgb(color)) {
			const arr = color.replace(/(?:\(|\)|rgb|RGB)*/g, '').split(',');
			return arr.map((item) => item / 255);
		}

		if (this.isRgba(color)) {
			const arr = color.replace(/(?:\(|\)|rgba|RGBA)*/g, '').split(',');
			const alpha = +arr.pop();
			return [...arr.map((item) => item / 255), alpha];
		}

		if (this.isHex(color)) {
			const rgb = this.hexToRgb(color);
			return this.toFloatArr(rgb);
		}

		if (this.isHexa(color)) {
			const rgba = this.hexaToRgba(color);
			return this.toFloatArr(rgba);
		}

		return color;
	}

	/**
	 * 颜色值转为数组
	 * @param color {string}
	 * @returns {string[]|*}
	 */
	static toArr(color) {
		if (this.isRgb(color)) {
			return color
				.replace(/(?:\(|\)|rgb|RGB)*/g, '')
				.split(',')
				.map((num) => +num);
		}

		if (this.isRgba(color)) {
			return color
				.replace(/(?:\(|\)|rgba|RGBA)*/g, '')
				.split(',')
				.map((num) => +num);
		}

		if (this.isHex(color)) {
			const rgb = this.hexToRgb(color);
			return this.toArr(rgb);
		}

		if (this.isHexa(color)) {
			const rgba = this.hexaToRgba(color);
			return this.toArr(rgba);
		}

		return color;
	}

	/**
	 * 颜色转指定透明度的 RGBA 形式
	 * @param color {string}
	 * @param alpha {number}
	 */
	static toRgba(color, alpha = 1) {
		const colorArr = this.toArr(color);

		if (colorArr.length === 4) colorArr.pop();

		return `rgba(${colorArr.join(',')},${alpha})`;
	}

	/**
	 * 颜色转RGB
	 * @param color
	 * @returns {string}
	 */
	static toRgb(color) {
		const colorArr = this.toArr(color);

		if (colorArr.length === 4) colorArr.pop();

		return `rgb(${colorArr.join(',')})`;
	}

	static isRgbOrRgba(color) {
		return /^(rgb|RGB)/.test(color);
	}

	static isRgb(color) {
		return /^(rgb\(|RGB\()/.test(color);
	}

	static isRgba(color) {
		return /^(rgba\(|RGBA\()/.test(color);
	}

	static isHex(color) {
		return /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(color);
	}

	static isHexa(color) {
		return /^#([0-9a-fA-f]{4}|[0-9a-fA-f]{8})$/.test(color);
	}
}
